﻿package mortal.game.scene3D.ai.ais
{
    import mortal.game.cache.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.scene3D.ai.base.*;
    import mortal.game.view.skill.*;

    public class PetAutoFightAI extends AutoFightAI
    {
        public static var isWorking:Boolean = false;

        public function PetAutoFightAI()
        {
            return;
        }// end function

        override public function start(param1:Function = null) : void
        {
            isWorking = true;
            super.start();
            AutoFightAI.isWorking = false;
            return;
        }// end function

        override public function stop(param1:Boolean = true) : void
        {
            isWorking = false;
            super.stop(param1);
            return;
        }// end function

        override public function startAIList() : void
        {
            if (_isCancelAll)
            {
                return;
            }
            if (!isWorking)
            {
                return;
            }
            if (_curAI != null)
            {
                AIFactory.instance.inAIData(_curAI.data);
                _curAI = null;
            }
            if (_aiList.length == 0)
            {
                return;
            }
            _curAI = _aiList.shift();
            _curAI.start(this.startAIList);
            return;
        }// end function

        override public function get isPassingNewMap() : Boolean
        {
            var _loc_1:IAICommand = null;
            if (!isWorking)
            {
                return false;
            }
            if (_curAI == null)
            {
                return false;
            }
            if (_curAI is PassAI || _curAI is DelayAI)
            {
                return true;
            }
            if (_aiList.length > 0)
            {
                _loc_1 = _aiList[(_aiList.length - 1)] as IAICommand;
                if (_loc_1 is PassAI || _curAI is DelayAI)
                {
                    return true;
                }
            }
            return false;
        }// end function

        override public function get isFighting() : Boolean
        {
            if (!isWorking)
            {
                return false;
            }
            if (_curAI == null)
            {
                return false;
            }
            if (_curAI is CollectAI || _curAI is FollowFightAI)
            {
                return true;
            }
            return false;
        }// end function

        override protected function get skillInfo() : SkillInfo
        {
            return Cache.instance.autoFight.getCanUsePetSkill();
        }// end function

    }
}
